package oop.ex2.expression;

import oop.ex2.exceptions.UnrecognizedVariable;

public class MinFunctionNode extends FunctionNode {
	private static final int NUMBER_OF_PARAMS = 1;
	private static boolean BOUNDED_PARAMETERS = false;
	
	/**
	 * Build a function node.
	 * @param matchedString The string that caused this function to be created.
	 */
	public MinFunctionNode(String matchedString) {
		super(matchedString, NUMBER_OF_PARAMS, BOUNDED_PARAMETERS);
	}

	@Override
	public double calculateNode() throws UnrecognizedVariable {
		double output = _children.get(0).calculateNode();
		for (ExpressionNode node : _children)
			output = Math.min(output, node.calculateNode());
		
		return output;
	}

}
